#pragma once
#include "../../CommonModule/comm.hpp"
#include "./Protocol.hpp"

class ProtocolCommonResp : public Protocol
{
public:
    ProtocolCommonResp()
        : Protocol(Type::CommonResp)
    {
    }

    virtual std::string serialize() override
    {
        Json::Value root;
        Json::FastWriter writer;
        root["type"] = _type;
        root["code"] = code;

        return writer.write(root);
    }
    virtual void deserialize(const Json::Value &root) override
    {
        _type = (Protocol::Type)root["type"].asInt();
        code = (Code)root["code"].asInt();
    }

    void setCode(Code code)
    {
        this->code = code;
    }

    int getCode()
    {
        return code;
    }

private:
    Code code;
};